$(function () {
    //商品分类
    $.get('/eshop/productType.do?m=pageAll',function (res) {
        res.data.forEach(function (e,i) {
            $(".classify>ul").append('<li> <h3><a href="javascript:void(0);" onclick="toClassify(\''+e.productTypeName+'\')"><i class="fa '+e.productTypeIcon+'"></i>'+e.productTypeName+'</a></h3></li>')
        })
    },'json')

    //商品分类
    $.get('/eshop/productType.do?m=pageAll',function (res) {
        res.data.forEach(function (e,i) {
            $("#nav-er>ul").append('<li> <h3><a href="javascript:void(0);" onclick="renderingBrand(\''+e.productTypeName+'\')"><i class="fa '+e.productTypeIcon+'"></i>'+e.productTypeName+'</a></h3></li>')
        })
    },'json')

    //搜索框下面的
    $.get('/eshop/searchHistory.do?m=pageAll',function (res) {
        res.data.forEach(function (e,i) {
            $(".hotkey").append('<a href="javascript:void(0);">'+e.searchWords+'</a>')
        })
    },'json')


    //搜索框点击事件
    $('.search-btn').click(function () {
        console.log($('#search-text').val());
        localStorage.setItem('search',$('#search-text').val());
        window.location='/eshop/reception/classify.jsp'
    })

})

//去购物详情页
function toGoodsDetail(str){
    $.get('/eshop/product.do',{m:'findByID',id:str},function (data) {
        window.location="/eshop/reception/goodsDetail.jsp"
    })
}

//分类点击方法
function toClassify(str) {
    console.log(str);
    localStorage.setItem("productTypeName",str);
    window.location="reception/classify.jsp";
}